home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / shadow-9.tar / shadow-9 / shadow-960129 / dialchk.c < prev    next >
C/C++ Source or Header  |  1995-12-17  |  3KB  |  85 lines

  1. /*
  2.  * Copyright 1989 - 1991, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by John F. Haugh, II
  16.  *      and other contributors.
  17.  * 4. Neither the name of John F. Haugh, II nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY JOHN HAUGH AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL JOHN HAUGH OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #include <stdio.h>
  35. #include "config.h"
  36. #include "defines.h"
  37. #include "dialup.h"
  38.  
  39. #ifndef    lint
  40. static char rcsid[] = "$Id: dialchk.c,v 1.1 1995/12/16 01:15:45 marekm Exp $";
  41. #endif
  42.  
  43. extern    char    *pw_encrypt();
  44.  
  45. /*
  46.  * Check for dialup password
  47.  *
  48.  *    dialcheck tests to see if tty is listed as being a dialup
  49.  *    line.  If so, a dialup password may be required if the shell
  50.  *    is listed as one which requires a second password.
  51.  */
  52.  
  53. int    dialcheck (tty, shell)
  54. char    *tty;
  55. char    *shell;
  56. {
  57.     char    *crypt ();
  58.     char    *getpass ();
  59.     struct    dialup    *dialup;
  60.     char    *pass;
  61.     char    *cp;
  62.  
  63.     setduent ();
  64.  
  65.     if (! isadialup (tty)) {
  66.         endduent ();
  67.         return (1);
  68.     }
  69.     if (! (dialup = getdushell (shell))) {
  70.         endduent ();
  71.         return (1);
  72.     }
  73.     endduent ();
  74.  
  75.     if (dialup->du_passwd[0] == '\0')
  76.         return (1);
  77.  
  78.     if (! (pass = getpass ("Dialup Password:")))
  79.         return (0);
  80.  
  81.     cp = pw_encrypt (pass, dialup->du_passwd);
  82.     bzero (pass, strlen (pass));
  83.     return (strcmp (cp, dialup->du_passwd) == 0);
  84. }
  85.